//
//  ShoppingCarItem.m
//  EJLX
//
//  Created by adc on 15/11/24.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "ShoppingCarItem.h"

@implementation ShoppingCarItem
+(ShoppingCarItem *)praseItemWithDictionary:(NSDictionary *)dict{
    ShoppingCarItem *item = [[ShoppingCarItem alloc] init];
    
    if (![dict[@"itemId"] isKindOfClass:[NSNull class]] ) {
        item.itemId = [dict[@"itemId"]intValue];
    }else{
        item.itemId = 0;
    }
   // item.itemId = [dict[@"itemId"]intValue];
    if (![dict[@"productId"]isKindOfClass:[NSNull class]]) {
        item.productId = [dict[@"productId"] intValue];
    }else{
        item.productId = 0;
    }
    
   // item.count = [dict[@"count"] intValue];
    if ( [dict[@"name"] isKindOfClass:[NSNull class]]) {
        item.name = @"";
    }else{
        item.name = dict[@"name"];
    }
    if ([dict[@"avatar"] isKindOfClass:[NSNull class]]) {
         item.image = @"";
    }else{
         item.image = dict[@"avatar"];
    }
    if ([dict[@"desc"] isKindOfClass:[NSNull class]]) {
       item.desc = @"";
    }else{
        item.desc = dict[@"desc"];
    }
    if (![dict[@"price"] isKindOfClass:[NSNull class]]) {
        item.price = [dict[@"price"] intValue];
    }else{
        item.price = 0;
    }
    if (![dict[@"discountPrice"] isKindOfClass:[NSNull class]]) {
        item.discountPrice = [dict[@"discountPrice"] intValue];
    }else{
        item.discountPrice = 0;
    }
    
    if (![dict[@"count"] isKindOfClass:[NSNull class]]) {
        item.count = [dict[@"count"] intValue];
    }else{
        item.count = 0;
    }
    
 
    return item;
}
@end
